package com.ssy.lingxi.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 邮件帮助类
 * @author 万宁
 * @version 2.0.0
 * @date 2020-07-18
 */
public class MailUtil {

    public static boolean isCorrect(String email, boolean ignoreEmpty) {
        if(!ignoreEmpty) {
            if (null == email || "".equals(email)) {
                return false;
            }
        }

        String regex = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(email);
        return m.matches();
    }
}
